<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xml:lang="en" lang="en">
	<h:head />
	<body>
		<ui:composition template="/rootWeb.xhtml">
	    <ui:define name="header">
	        <title>订单管理</title>
	        <script type="text/javascript">
				//页面载入时注册
	        	jQuery(document).ready(function(){
	        		//鼠标移入
					jQuery("#orderListTable_data tr").live("mouseover", function() {
					  	jQuery(this).css("background-color","#CCCCCC");
					});
					//鼠标移出
					jQuery("#orderListTable_data tr").live("mouseout", function() {
					  	jQuery(this).css("background-color","white");
					});
				});
				//重置
				function resetQueryCondition(){
					jQuery("#queryOrderCode").val("");
					jQuery("#queryOrderState").val("");
					jQuery("#queryOrderCreate_input").val("");
				}
			</script>
			<style type="text/css">
				
			</style>
		</ui:define>
	    <ui:define name="body">
	    	<h:form id="form" prependId="false">
	    		<div style="white-space:nowrap;width: 100%;overflow:inherit;"> 
	    		<h:panelGrid  columns="6" style="width: 100%" >
					<h:outputLabel for="queryOrderCode" value="订单编号：" />
					<p:inputText id="queryOrderCode" value="#{orderManageAction.queryOrderMain.orderCode}"  size="15"/>
					<h:outputLabel for="queryOrderState" value="订单状态：" />
    				<h:selectOneMenu id="queryOrderState" value="#{orderManageAction.queryOrderMain.orderState}" style="width: 170px;height:25px;font-size: 17.6px">  
    				 	<f:selectItem itemLabel="请选择"  itemValue=""/>
		                <f:selectItems value="#{orderManageAction.orderStateItems}"/>
		            </h:selectOneMenu>
					<h:outputLabel for="queryOrderCreate" value="下单日期："/>
    				<p:calendar id="queryOrderCreate" value="#{orderManageAction.queryOrderMain.createDate}" size="15"
    					timeZone="GMT+8" pattern="yyyy-MM-dd" showButtonPanel="true" navigator="true"/>
    				<p:spacer/><p:spacer/><p:spacer/><p:spacer/>
    				<h:panelGrid columns="2">
	   				    <p:commandButton value="查询" action="#{orderManageAction.doFilterOrderList}"  update=":form:orderListTable"/>
	    				<p:commandButton value="重置" onclick="resetQueryCondition()" />
    				</h:panelGrid>
    				<h:panelGrid columns="3"> 
    				    <p:commandButton value="新增" action="#{orderManageAction.addOrder}" update=":form:addOrderDlgID" oncomplete="addOrderDlg.show()"/>
    				    <p:commandButton value="所属模具" oncomplete="viewMoldDlg.show()" update=":form:viewMoldDlgID" />
	    			    <p:commandButton value="导入导出"/>
    			    </h:panelGrid>
				</h:panelGrid><p/>
				<p:dataTable id="orderListTable" value="#{orderManageAction.orderMainList}" var="order" rowKey="#{order}" emptyMessage="没有订单！"
	    				paginator="true" rows="10"  	rowsPerPageTemplate="5,10,15"	paginatorAlwaysVisible="false" 	paginatorPosition="bottom" currentPageReportTemplate="查询到{totalRecords}条记录，本页显示{startRecord}～{endRecord}；第{currentPage}/{totalPages}页"
               			paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"   >
               			<f:facet name="header">订单列表</f:facet>
               			<p:column headerText="订单号">#{order.orderCode}</p:column>
               			<p:column headerText="总金额"  style="text-align:right;">
               				<h:outputText value="#{order.totalAmount}"  >
               					<f:convertNumber type="number" pattern="#,###.##" minFractionDigits="2"/>
               				</h:outputText>
               			</p:column>
               			<p:column headerText="加工费"  style="text-align:right;">
               				<h:outputText value="#{order.manufactureAmount}"  >
               					<f:convertNumber type="number" pattern="#,###.##" minFractionDigits="2"/>
               				</h:outputText>
               			</p:column>
               			<p:column headerText="订单状态" >
               				<h:selectOneMenu value="#{order.orderState}" disabled="true">  
					            <f:selectItems value="#{orderManageAction.orderStateItems}"/>
					         </h:selectOneMenu>
						</p:column>
               			<p:column headerText="是否加急">
               				<h:outputText value="是" rendered="#{order.urgentFlag eq 'Y'}"  />
               				<h:outputText value="否" rendered="#{order.urgentFlag eq 'N'}"  />
               			</p:column>
               			<p:column headerText="总支数"  style="text-align:right;">
               				<h:outputText value="#{order.totalQuantity}"  >
               					<f:convertNumber type="number" pattern="#,###" />
               				</h:outputText>
               			</p:column>
               			<p:column headerText="总重量"  style="text-align:right;">
               				<h:outputText value="#{order.totalWeight}"  >
               					<f:convertNumber type="number" pattern="#,###.##" minFractionDigits="2"/>
               				</h:outputText>
               			</p:column>
               			<p:column headerText="下单日期">
               				<h:outputText value="#{order.createDate}" >
               					<f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8" />
               				</h:outputText>
               			</p:column>
               			<p:column headerText="操作">
               				<p:commandLink value="查看" style="color:RED;margin-right:5px"/>
               			</p:column>
               	</p:dataTable>
               	
               	
               	<!-- 新增订单 -->
               	<p:dialog id="addOrderDlgID" header="新增订单" widgetVar="addOrderDlg" modal="true" resizable="true" >
               		<p:outputPanel id="addOrderMainPanel"  style="width: 100%" >
              			<table><tr><td>
							<h:outputLabel for="addOrderCreateDate" value="下单日期："/>
						</td><td>
							<h:outputText id="addOrderCreateDate" value="#{orderManageAction.addOrderMain.createDate}" >
               					<f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8" />
               				</h:outputText>
               			</td><td>
	              			<h:outputLabel for="addOrderCode" value="订单编号："/>
	              		</td><td>
					    	<h:outputText id="addOrderCode"  value="#{orderManageAction.addOrderMain.orderCode}" styleClass="outputInfoFont" />
					    </td><td>
               				<h:outputLabel rendered="false" for="addOrderCustomerName" value="下单客户："/>
               			</td><td>
					    	<h:outputText rendered="false" id="addOrderCustomerName"  value="#{orderManageAction.addOrderMain.customerName}" styleClass="outputInfoFont" />
					    </td></tr>
					    <tr><td>
               				<h:outputLabel for="addOrderManufactureAmount" value="加工费："/>
               			</td><td>
					    	<p:inputText id="addOrderManufactureAmount"  value="#{orderManageAction.addOrderMain.manufactureAmount}"  style="font-weight: bold;width:160px;text-align:right;ime-mode:disabled" 
					    			onfocus="replaceComma(id,value);" onkeyup="checkMoneyOnKeyUp(this.id, this.value, 20, 2)" >
					    		 <f:convertNumber type="number" pattern="#,###.##" minFractionDigits="2"/>
					    	</p:inputText>
					    </td><td>
               				<h:outputLabel for="addOrderTotalAmount" value="订单金额："/>
               			</td><td>
					    	<p:inputText id="addOrderTotalAmount"  value="#{orderManageAction.addOrderMain.totalAmount}"  style="font-weight: bold;width:160px;text-align:right;;ime-mode:disabled" 
					    			onfocus="replaceComma(id,value);" onkeyup="checkMoneyOnKeyUp(this.id, this.value, 20, 2)"  >
					    		 <f:convertNumber type="number" pattern="#,###.##" minFractionDigits="2"/>
					    	</p:inputText>
					    </td><td>
               				<h:outputLabel for="addOrderSelectedAlPrice" value="铝价："/>
               			</td><td>
					    	<p:inputText id="addOrderSelectedAlPrice"  value="#{orderManageAction.addOrderMain.selectedAlPrice}" readonly="false" style="font-weight: bold;width:160px;text-align:right" >
					    		 <f:convertNumber type="number" pattern="#,###.##" minFractionDigits="2"/>
					    	</p:inputText>
					    </td></tr>
					    <tr><td>	
               				<h:outputLabel for="addOrderTotalQuantity" value="总支数："/>
               			</td><td>
					    	<p:inputText id="addOrderTotalQuantity"  value="#{orderManageAction.addOrderMain.totalQuantity}" readonly="true" style="font-weight: bold;width:160px;text-align:right" >
					    		 <f:convertNumber type="number" pattern="#,###" />
					    	</p:inputText>
					    </td><td>
               				<h:outputLabel for="addOrderTotalWeight" value="总重量："/>
               			</td><td>
					    	<p:inputText id="addOrderTotalWeight"  value="#{orderManageAction.addOrderMain.totalWeight}"  readonly="true" style="font-weight: bold;width:160px;text-align:right" >
					    		 <f:convertNumber type="number" pattern="#,###.##" minFractionDigits="2"/>
					    	</p:inputText>
					    </td><td>
               				<h:outputLabel for="addOrderUrgentFlag" value="是否加急："/>
               			</td><td>
               				<h:selectOneMenu id="addOrderUrgentFlag" value="#{orderManageAction.addOrderMain.urgentFlag}" style="font-weight: bold;width:160px" >  
					            <f:selectItems value="#{orderManageAction.yesOrNoItems}"/>
					         </h:selectOneMenu>
					     </td></tr>
					     <tr><td >
						         <h:outputLabel for="addOrderDesc" value="订单备注："/>
						  </td><td colspan="5">
						         <p:inputTextarea id="addOrderDesc" value="#{orderManageAction.addOrderMain.orderDesc}" rows="1" autoResize="false"  
						         		maxlength="100" style="width:700px" />
						  </td></tr></table>
               		</p:outputPanel><p/>
               		<div style="overflow: auto">
               		<p:dataTable id="addOrderDetailTable" value="#{orderManageAction.addOrderDetailList}" var="addOrderDetail" rowKey="#{addOrderDetail}" emptyMessage="没有记录！"
               			selection="#{orderManageAction.deleteOrderDetailList}" rowIndexVar="rowIndex"
	    				paginator="true" rows="4"  	rowsPerPageTemplate="4,10,15"	paginatorAlwaysVisible="false" 	paginatorPosition="bottom" currentPageReportTemplate="{currentPage} / {totalPages}"
               			paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"   >
               			<p:column selectionMode="multiple" />
               			<p:column headerText="" style="width:10px">#{rowIndex+1}</p:column>
               			<p:column headerText="系列">
               				<p:inputText  value="#{addOrderDetail.mold.moldSeries.seriesName}"  style="width:60px" readonly="true"/>
               			</p:column>
               			<p:column headerText="品名">
               				<h:selectOneMenu value="#{addOrderDetail.mold.moldName}" style="width:80px" disabled="true">  
               						<f:selectItem itemLabel=""  itemValue=""/>
					                <f:selectItems value="#{orderManageAction.moldNameItems}"/>
					            </h:selectOneMenu>
               				<p:commandLink value="选择" style="color:RED" action="#{orderManageAction.setSelectMoldOrderDetail(addOrderDetail)}"
               					oncomplete="selectMoldDlg.show()" update=":form:selectMoldDlgID"/>
               			</p:column>
               			<p:column headerText="型号">
               				<p:inputText  value="#{addOrderDetail.mold.moldNumber}"  style="width:100px" readonly="true"/>
               			</p:column>
               			<p:column headerText="支重">
               				<p:inputText  value="#{addOrderDetail.mold.moldPerWeight}"  style="width:50px;text-align:right" readonly="true"/>
               			</p:column>
               			<p:column headerText="订货重量">
               				<p:inputText  value="#{addOrderDetail.detailWeight}"  style="width:60px;text-align:right" readonly="true">
               					<f:convertNumber type="number" pattern="#,###.##" minFractionDigits="2"/>
               				</p:inputText>
               			</p:column>
               			<p:column headerText="加工费">
               				<p:inputText  value="#{addOrderDetail.manufactureAmount}"  style="width:60px;text-align:right;ime-mode:disabled" 
               						onfocus="replaceComma(id,value);" onkeyup="checkMoneyOnKeyUp(this.id, this.value, 20, 2)" >
               					<p:ajax event="blur" listener="#{orderManageAction.onDetailManufactureAmountBlurWhenAdd}" 
               							update=":form:addOrderDetailTable,:form:addOrderMainPanel" />
               					<f:convertNumber type="number" pattern="#,###.##" minFractionDigits="2"/>
               				</p:inputText>
               			</p:column>
               			<p:column headerText="支数">
               				<p:inputText value="#{addOrderDetail.detailQuantity}"  style="width:50px;text-align:right;ime-mode:disabled" maxlength="20" 
               					onkeyup="onlyNumberCheck(this.id)"  onfocus="replaceComma(id,value);" >
               					<p:ajax event="blur" listener="#{orderManageAction.onDetailQuantityBlurWhenAdd}" 
               							update=":form:addOrderDetailTable,:form:addOrderMainPanel" />
               					<f:convertNumber type="number" pattern="#,###" />
               				</p:inputText>
               			</p:column>
               			<p:column headerText="长度">
               				<p:inputText  value="#{addOrderDetail.detailLength}"  style="width:50px;text-align:right;ime-mode:disabled" maxlength="20"  
               					onfocus="replaceComma(id,value);" onkeyup="checkMoneyOnKeyUp(id, value, 20, 2)" >
               					<f:convertNumber type="number" pattern="#,###.##" minFractionDigits="2"/>
               				</p:inputText>
               			</p:column>
               			<p:column headerText="贴膜品牌">
               				<p:inputText  value="#{addOrderDetail.pasteBrand}"  style="width:80px" maxlength="30" />
		    				<h:selectOneMenu rendered="false" value="#{addOrderDetail.pasteBrand}" style="width:80px">  
		    					<f:selectItem itemLabel="请选择" itemValue="" />
				                <f:selectItems value="#{orderManageAction.pasteBrandItems}"/>
				            </h:selectOneMenu>
		    			</p:column>
               			<p:column headerText="表面处理" style="width:80px">
		    				<h:selectOneMenu value="#{addOrderDetail.surfaceHandleWay}" style="width:60px">  
				                <f:selectItem itemLabel="请选择" itemValue="" />
				                <f:selectItems value="#{orderManageAction.surfaceHandleItems}"/>
				            </h:selectOneMenu>
		    			</p:column>
               			<p:column headerText="包装方式">
		    				<h:selectOneMenu value="#{addOrderDetail.packingWay}" style="width:80px">  
		    					<f:selectItem itemLabel="请选择" itemValue="" />
				                <f:selectItems value="#{orderManageAction.packingWayItems}"/>
				            </h:selectOneMenu>
		    			</p:column>
		    			<f:facet name="footer">
		    				<p:commandButton value="添加"  action="#{orderManageAction.addOrderDetail}" update=":form:addOrderDetailTable"/><p:spacer width="5"/>
		    				<p:commandButton value="删除" action="#{orderManageAction.deleteOrderDetail}" update=":form:addOrderDetailTable,:form:addOrderMainPanel"
		    					oncomplete="if(this.args.error){alert(this.args.error)}"/>
		    			</f:facet>
               		</p:dataTable>
               		</div>
               		<f:facet name="footer">
		    				<p:commandButton value="保存" action="#{orderManageAction.saveOrder}"  update=":form:orderListTable"
		    					oncomplete="if(this.args.error){alert(this.args.error)}else{alert(this.args.msg);addOrderDlg.hide();}" />
		    				<p:spacer width="5"/>
		    				<p:commandButton value="关闭" onclick="addOrderDlg.hide();" type="button"/>
		    			</f:facet>
               	</p:dialog>
               	
               	<!-- 选择客户模具 -->
               	<p:dialog id="selectMoldDlgID" header="选择模具" widgetVar="selectMoldDlg" modal="true" resizable="false" >
               			<p:dataTable id="selectMoldTable" value="#{orderManageAction.customerMoldList}" var="customerMold" rowKey="#{customerMold}" emptyMessage="没有记录！"
               				selection="#{orderManageAction.selectedCustomerMold}"
		    				paginator="true" rows="10"  	rowsPerPageTemplate="5,10,15"	paginatorAlwaysVisible="false" 	paginatorPosition="bottom" currentPageReportTemplate="{currentPage} / {totalPages}"
	               			paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"   >
	               			<p:column selectionMode="single"/>
	               			<p:column headerText="系列">
	               				<h:outputText value="#{customerMold.mold.moldSeries.seriesName}"/>
	               			</p:column>
               				<p:column headerText="品名">
               					<h:selectOneMenu value="#{customerMold.mold.moldName}" style="width:80px" disabled="true">  
					                <f:selectItems value="#{orderManageAction.moldNameItems}"/>
					            </h:selectOneMenu>
               				</p:column>
               				<p:column headerText="模具壁厚">
               					<h:outputText value="#{customerMold.mold.moldThickness}"/>
               				</p:column>
               				<p:column headerText="模具支重">
               					<h:outputText value="#{customerMold.mold.moldPerWeight}"/>
               				</p:column>
               				<p:column headerText="开模日期">
               					<h:outputText value="#{customerMold.mold.createDate}">
               						<f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8" />
               					</h:outputText>
               				</p:column>
               				<p:column headerText="开模工厂">
               					<h:outputText value="#{customerMold.mold.factoryName}"/>
               				</p:column>
               			</p:dataTable>
               			<f:facet name="footer">
		    				<p:commandButton value="确定" action="#{orderManageAction.setMoldToOrderDetail}"
		    					update=":form:addOrderDlgID" oncomplete="selectMoldDlg.hide();addOrderDlg.show();"/>
		    				<p:commandButton value="取消" oncomplete="selectMoldDlg.hide()"/>
		    			</f:facet>
               	</p:dialog>
               	
               	<!-- 查看客户模具 -->
               	<p:dialog id="viewMoldDlgID" header="查看所有模具" widgetVar="viewMoldDlg" modal="true" resizable="false" >
               			<p:dataTable value="#{orderManageAction.customerMoldList}" var="customerMold" rowKey="#{customerMold}" emptyMessage="没有模具！"
		    				paginator="true" rows="10"  	rowsPerPageTemplate="5,10,15"	paginatorAlwaysVisible="false" 	paginatorPosition="bottom" currentPageReportTemplate="{currentPage} / {totalPages}"
	               			paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"   >
	               			<p:column headerText="系列">
	               				<h:outputText value="#{customerMold.mold.moldSeries.seriesName}"/>
	               			</p:column>
               				<p:column headerText="品名">
               					<h:selectOneMenu value="#{customerMold.mold.moldName}" style="width:80px" disabled="true">  
					                <f:selectItems value="#{orderManageAction.moldNameItems}"/>
					            </h:selectOneMenu>
               				</p:column>
               				<p:column headerText="模具壁厚">
               					<h:outputText value="#{customerMold.mold.moldThickness}"/>
               				</p:column>
               				<p:column headerText="模具支重">
               					<h:outputText value="#{customerMold.mold.moldPerWeight}"/>
               				</p:column>
               				<p:column headerText="开模日期">
               					<h:outputText value="#{customerMold.mold.createDate}">
               						<f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8" />
               					</h:outputText>
               				</p:column>
               				<p:column headerText="开模工厂">
               					<h:outputText value="#{customerMold.mold.factoryName}"/>
               				</p:column>
               			</p:dataTable>
               			<f:facet name="footer">
		    				<p:commandButton value="关闭" oncomplete="viewMoldDlg.hide()"/>
		    			</f:facet>
               	</p:dialog>
               	</div>
			</h:form>
	    </ui:define>
		</ui:composition>
	</body>
</html>
